<template>
	<div class="conMain">
		<el-card class="box-card">
			<div slot="header" class="topfix">
				<el-form :inline="true" :model="params" size="small" class="goodsForm" label-width="100px">
					<el-form-item label="ID">
						<el-input v-model="params.s_id" clearable placeholder="请输入商品ID" />
					</el-form-item>
					<el-form-item label="商品名称">
						<el-input v-model="params.s_name" clearable placeholder="请输入商品名称" />
					</el-form-item>
					<el-form-item label="结算类型">
						<el-select v-model="params.s_jslx" clearable placeholder="请选择">
							<el-option v-for="(item,index) in jslxlist" :label="item.txt" :value="item.val" />
						</el-select>
					</el-form-item>
					<el-form-item label="所属渠道">
						<el-select v-model="params.s_pass_id" filterable clearable placeholder="请选择">
							<el-option v-for="(item,index) in passlist" :label="item.name" :value="item.id" />
						</el-select>
					</el-form-item>
					<el-form-item label="状态">
						<el-select v-model="params.s_status" clearable placeholder="请选择">
							<el-option v-for="(item,index) in statuslist" :label="item.txt" :value="item.val" />
						</el-select>
					</el-form-item>
					<el-form-item label=" ">
						<el-button type="primary" size="small" class="searchBtn" icon="el-icon-search"
							@click="handleSearch">搜索</el-button>
					</el-form-item>
				</el-form>
				<div style="text-align: right;">
					<el-button v-has="'passage/goods/add'" type="primary" size="small" class="ml10" plain
						@click="add"><i class="el-icon-plus" /> 添加商品</el-button>
				</div>
			</div>
			<el-table v-loading="loading" :data="list" style="width: 100%" :empty-text="emtypetxt">
				<el-table-column prop="id" label="ID" align="center" width="100" />
				<el-table-column prop="name" label="商品名称" :show-overflow-tooltip="true" align="center"
					min-width="150" />
				<el-table-column prop="image" label="图片" align="center">
					<template slot-scope="scope">
						<el-image style="width:40px;height:40px" :src="scope.row.image"
							:preview-src-list="[scope.row.image]">
							<div slot="error" class="image-slot" />
						</el-image>
					</template>
				</el-table-column>
				<el-table-column prop="passage.name" label="所属渠道" align="center" />
				<el-table-column prop="type" label="类型" align="center">
					<template slot-scope="scope">
						<span v-if="scope.row.type === 1">联通卡</span>
						<span v-else-if="scope.row.type === 2">移动卡</span>
						<span v-else-if="scope.row.type === 3">电信卡</span>
						<span v-else-if="scope.row.type === 4">广电卡</span>
					</template>
				</el-table-column>
				<el-table-column prop="type" label="结算类型" align="center">
					<template slot-scope="scope">
						<span v-if="scope.row.jslx === 1">日结</span>
						<span v-else-if="scope.row.jslx === 2">月结</span>
					</template>
				</el-table-column>
				<el-table-column prop="fee" label="最高佣金" align="center" min-width="80" />
				<el-table-column prop="sc_money" label="首充限制" align="center" min-width="160" />
				<el-table-column prop="limit_jh" label="激活限制" align="center" min-width="80" />
				<el-table-column prop="limit_code" label="验证码" align="center">
					<template slot-scope="scope">
						<span v-if="scope.row.limit_code === 0">不需要</span>
						<span v-else-if="scope.row.limit_code === 1">需要</span>
					</template>
				</el-table-column>

				<el-table-column prop="description" label="描述" :show-overflow-tooltip="true" align="center" />
				<el-table-column prop="weigh" label="排序" align="center" />

				<el-table-column label="选号" align="center">
					<template slot-scope="scope">
						<el-tag v-if="scope.row.selectp === 1" type="success" size="mini"
							disable-transitions>选号</el-tag>
						<el-tag v-if="scope.row.selectp === 0" type="info" size="mini" disable-transitions>不选号</el-tag>
					</template>
				</el-table-column>

				<el-table-column label="状态" align="center">
					<template slot-scope="scope">
						<el-tag v-if="scope.row.status === 1" type="success" size="mini" disable-transitions>上线</el-tag>
						<el-tag v-if="scope.row.status === -1" type="info" size="mini" disable-transitions>下线</el-tag>
					</template>
				</el-table-column>
				<el-table-column prop="createtime" label="创建时间" align="center" width="200" />
				<el-table-column fixed="right"  label="操作" align="center" width="180">
					<template slot-scope="scope">
						<el-link v-has="'passage/goods/edit'" :underline="false" type="primary" title="编辑"
							@click="edit(scope.row)">编辑</el-link>
						<el-link v-has="'passage/goods/reset'" class="ml10" :underline="false" type="warning"
							title="佣金重置" @click="reset(scope.row)">重置</el-link>
						<!-- <el-link v-has="'passage/goods/reset'" class="ml10" :underline="false" type="danger" title="佣金同步" @click="resetOne(scope.row)">同步</el-link> -->

					</template>
				</el-table-column>
			</el-table>
			<div class="pagination">
				<el-pagination :current-page="params.page" :page-sizes="[10, 20, 50, 100]" :page-size="params.pagesize"
					layout="total, sizes, prev, pager, next, jumper" :total="total" @size-change="handleSizeChange"
					@current-change="handleCurrentChange" />
			</div>
		</el-card>
		<el-dialog :title="sub.id==0?'添加商品':'编辑商品'" :visible.sync="dialogVisible" :close-on-click-modal="false" center
			width="40%">
			<el-form ref="ruleForm" :model="sub" :rules="rules" label-width="110px">
				<el-form-item label="商品名称" prop="name">
					<el-input v-model="sub.name" clearable placeholder="请输入商品名称" />
				</el-form-item>
				<el-row>
					<el-col :span="12">
						<el-form-item label="所属渠道" prop="pass_id">
							<el-select v-model="sub.pass_id" style="width:100%;" filterable clearable placeholder="请选择">
								<el-option v-for="(item,index) in passlist" :label="item.name" :value="item.id" />
							</el-select>
						</el-form-item>
					</el-col>
					<el-col :span="12">
						<el-form-item label="类型" prop="type">
							<el-select v-model="sub.type" style="width:100%;" clearable placeholder="请选择" @change="changeSubType">
								<el-option v-for="(item,index) in typelist" :label="item.txt" :value="item.val" />
							</el-select>
						</el-form-item>
					</el-col>
				</el-row>
				<el-form-item label="主图：" prop="image">
					<div class="upLoadPicBox" @click="modalPicTap('1')">
						<div v-if="sub.image" class="upictrue"><img :src="sub.image"></div>
						<div v-else class="upLoad">
							<i class="el-icon-camera cameraIconfont" />
						</div>
					</div>
				</el-form-item>
				<el-form-item label="自动结算" prop="zdjs">
					<el-radio-group v-model="sub.zdjs">
					<el-radio label="0">否</el-radio>
					<el-radio label="1">是</el-radio>
					</el-radio-group>
					<p style='color:red'>
					关闭后，系统将只同步数据，订单需要手动或者导入结算
					</p>
				</el-form-item>
				<el-form-item label="佣金" prop="fee">
					<el-input v-model="sub.fee" type="number" clearable placeholder="">
						<template slot="append">元</template>
					</el-input>
				</el-form-item>
				<el-form-item label="默认差价" prop="default_diff" v-if="sub.id==0">
					<el-input v-model="sub.default_diff" type="number" clearable placeholder="请输入默认差价">
						<template slot="append">元</template>
					</el-input>
				</el-form-item>
				<div style="margin-bottom: 20px;">
					<el-form-item v-for="(item, index) in sub.kaka" :key="index" style="margin-bottom: 6px!important;"
						:label="index==0?'商品参数':''">
						<div class="wdgroup" style="display: flex;flex-wrap: wrap;justify-content: flex-start;">
							<el-input v-model="sub.kaka[index]['goodsid']" placeholder="商品ID"
								style="width:42%!important;margin-right: 10px;" />
							<el-input v-model="sub.kaka[index]['name']" placeholder="名称"
								style="width:42%!important;margin-right: 10px;" />
							<el-button v-if="index>0" type="danger" plain="" size="mini" icon="el-icon-delete"
								@click.prevent="removeparams(index)" />
						</div>
					</el-form-item>
					<el-form-item label="">
						<el-button size="mini" @click="addparams()">+追加</el-button>
					</el-form-item>
				</div>
				<el-form-item label="商品描述" prop="description">
					<el-input v-model="sub.description" type="textarea" placeholder="用户可见，例如:19元/月,腾讯系app免流量等" />
				</el-form-item>
				<el-form-item label="推广要求" prop="memo">
					<el-input v-model="sub.memo" clearable placeholder="代理可见，例如:首充大于50，必须3天内激活，当月不能销户等" />
				</el-form-item>
				<el-form-item label="结算类型" prop="status">
					<el-radio-group v-model="sub.jslx">
						<el-radio label="1">日结</el-radio>
						<el-radio label="2">月结</el-radio>
					</el-radio-group>
				</el-form-item>
				<el-form-item label="结算方式" prop="jsfs">
					<el-input v-model="sub.jsfs" clearable placeholder="" />
				</el-form-item>
				<el-form-item label="不结算条件" prop="bjsfs">
					<el-input v-model="sub.bjsfs" clearable placeholder="" />
				</el-form-item>
				<el-row>
					<el-col :span="12">
						<el-form-item label="套餐归属地">
							<el-input v-model="sub.tcgsd" clearable placeholder="" />
						</el-form-item>
					</el-col>
					<!-- <el-col :span="12">
						<el-form-item label="年龄限制">
							<el-input v-model="sub.nlxz" clearable placeholder="" />
						</el-form-item>
					</el-col> -->
				</el-row>
				<el-form-item label="禁发地区" prop="jfdq">
					<el-input v-model="sub.jfdq" clearable placeholder="" />
				</el-form-item>
				<el-form-item label="温馨提示" prop="limitcontent">
					<el-input v-model="sub.limitcontent" clearable placeholder="" />
				</el-form-item>
				<el-row>
					<el-col :span="12">
						<el-form-item label="页面配置">
							<el-input v-model="sub.page_code" clearable placeholder="" />
						</el-form-item>
					</el-col>
					<el-col :span="12">
						<el-form-item label="页面模板">
							<el-select v-model="sub.page_mb" style="width:100%;" clearable placeholder="请选择">
								<el-option v-for="(item,index) in mblist" :label="item.txt" :value="item.val" />
							</el-select>
						</el-form-item>
					</el-col>
				</el-row>

				<el-row>
					<el-col :span="12">
						<el-form-item label="首充限制" prop="sc_money">
							<el-input v-model="sub.sc_money" type="number" clearable placeholder="">
								<template slot="append">元</template>
							</el-input>
						</el-form-item>
					</el-col>
					<el-col :span="12">
						<el-form-item label="激活限制">
							<el-input v-model="sub.limit_jh" type="number" clearable placeholder="0为不限制">
								<template slot="append">秒</template>
							</el-input>
						</el-form-item>
					</el-col>
				</el-row>

				<el-row>
				<el-col :span="12">
					<el-form-item label="最小年龄">
					<el-input v-model="sub.small_age" type="number" clearable placeholder="0为不限制">
						<template slot="append">岁</template>
					</el-input>
					</el-form-item>
				</el-col>
				<el-col :span="12">
					<el-form-item label="最大年龄">
					<el-input v-model="sub.big_age" type="number" clearable placeholder="0为不限制">
						<template slot="append">岁</template>
					</el-input>
					</el-form-item>
				</el-col>
				</el-row>

				<el-row>
					<el-col :span="12">

						<el-form-item label="验证码" prop="limit_code">
							<el-select v-model="sub.limit_code" style="width:100%;" clearable placeholder="请选择">
								<el-option label="不需要" value="0" />
								<el-option label="需要" value="1" />
							</el-select>
						</el-form-item>

					</el-col>
				</el-row>

				<el-form-item label="排序">
					<el-input v-model="sub.weigh" type="number" clearable placeholder="数字越大越靠前" />
				</el-form-item>
				<el-form-item label="状态" prop="status">
					<el-radio-group v-model="sub.status">
						<el-radio label="1">上线</el-radio>
						<el-radio label="-1">下线</el-radio>
					</el-radio-group>
				</el-form-item>
				<el-form-item label="选号" prop="selectp">
					<el-radio-group v-model="sub.selectp">
						<el-radio label="1">选号</el-radio>
						<el-radio label="0">不选号</el-radio>
					</el-radio-group>
				</el-form-item>
				<el-form-item label="转单" prop="selectp">
					<el-radio-group v-model="sub.zd">
						<el-radio label="0">不转</el-radio>
						<el-radio label="1">手动</el-radio>
						<el-radio label="2">自动</el-radio>
					</el-radio-group>
				</el-form-item>
				<el-form-item label="转单商品" prop="pass_id">
					<el-select v-model="sub.zdid" style="width:100%;" filterable clearable placeholder="请选择">
						<el-option v-for="(item,index) in goodslist" :label="item.name" :value="item.id" />
					</el-select>
				</el-form-item>
				<el-form-item label="下单限量" prop="selectp">
					<el-radio-group v-model="sub.xd">
						<el-radio label="0">无</el-radio>
						<el-radio label="1">限量次日提</el-radio>
						<el-radio label="4">限量不重提</el-radio>
						<el-radio label="2">限量转单</el-radio>
						<el-radio label="3">满量</el-radio>
					</el-radio-group>
					<p style="color:red" v-if="sub.xd==1">到达限量标准订单第二天自动提交</p>
					<p style="color:red" v-if="sub.xd==4">到达限量标准订单将不在任何后续操作</p>
					<p style="color:red" v-if="sub.xd==2">到达限量标准后订单自动转单</p>
					<p style="color:red" v-if="sub.xd==3">第二天状态自动变为限量，且订单自动提交</p>
				</el-form-item>
				<el-form-item label="限量数量">
					<el-input v-model="sub.xdnum"  type="number" clearable placeholder="" />
				</el-form-item>
				<el-form-item label="固定归属地">
					<el-input v-model="sub.address_fixed" clearable placeholder="" />
				</el-form-item>
				   <el-row>
					<el-form-item label="禁发地区" prop="limit_order_city">
						<el-cascader
							v-model="sub.limit_order_city"
							:options="sub.options"
							:props="sub.props"
							collapse-tags
							clearable
							style="width:100%;"
							@focus="setCityList"
						/>
					</el-form-item>
				   </el-row>
				<el-form-item label="奖励方式" prop="type_reward">
					<el-radio-group v-model="sub.type_reward">
						<el-radio label="0">首充奖励</el-radio>
						<el-radio label="1">激活奖励</el-radio>
					</el-radio-group>
				</el-form-item>
			</el-form>
			<div slot="footer" class="dialog-footer">
				<el-button @click="dialogVisible = false">取 消</el-button>
				<el-button type="primary" @click="subForm('ruleForm')">确定</el-button>
			</div>
		</el-dialog>
		<el-dialog title="佣金同步" :visible.sync="resetOneShow" :close-on-click-modal="false" center width="36%">

			<div style="color:#ff5500;margin-bottom: 20px;">重要提示：该同步操作只对一级代理有效</div>

			<el-form label-width="110px">
				<el-form-item label="同步商品">
					<el-cascader ref="tree" v-model="subset.goods_id" style="width:100%;" :options="glist"
						:show-all-levels="true" :props="{ emitPath:false }" clearable />
				</el-form-item>
			</el-form>
			<div slot="footer" class="dialog-footer">
				<el-button @click="resetOneShow = false">取 消</el-button>
				<el-button type="primary" @click="subReset">确定</el-button>
			</div>
		</el-dialog>
		<el-dialog title="差价佣金" :visible.sync="rrshow" :close-on-click-modal="false" center width="36%" :before-close='rrqx'>

			<!-- <div style="color:#ff5500;margin-bottom: 20px;">重要提示：该同步操作只对一级代理有效</div> -->

			<el-form label-width="110px">
				<el-form-item label="差价类型" prop="type_reward">
					<el-radio-group v-model="form.type">
						<el-radio label="1">固定差价</el-radio>
						<el-radio label="2">相对差价</el-radio>
					</el-radio-group>
				</el-form-item>
				<el-form-item label="商品差价">
					<el-input v-model="form.fee" clearable placeholder="请输入佣金" />
				</el-form-item>
			</el-form>
			<div slot="footer" class="dialog-footer">
				<el-button @click="rrqx">取 消</el-button>
				<el-button type="primary" @click="rrform">确定</el-button>
			</div>
		</el-dialog>

	</div>
</template>

<script>
	import {
		goods_index,
		goods_add_post,
		goods_edit_post,
		passage_list,
		goods_list,
		goods_reset,
		goods_city_list,
		goods_reset_get
	} from '@/api/passage'
	import {
		muban_list
	} from '@/api/mubanPage'

	export default {
		data() {
			return {
				rrshow:false,
				rrid:'',
				form:{
					type:'1',
					fee:'',
				},
				total: 0,
				loading: true,
				emtypetxt: '',
				list: [],
				passlist: [], // 渠道列表
				goodslist: [], // 商品列表
				typelist: [{
					val: '1',
					txt: '联通卡'
				}, {
					val: '2',
					txt: '移动卡'
				}, {
					val: '3',
					txt: '电信卡'
				}, {
					val: '4',
					txt: '广电卡'
				}],
				statuslist: [{
					val: '1',
					txt: '上线'
				}, {
					val: '-1',
					txt: '下线'
				}],
				jslxlist: [{
					val: '1',
					txt: '日结'
				}, {
					val: '2',
					txt: '月结'
				}],
				mblist: [
					// { val: '1', txt: '腾讯大王卡' },
					// { val: '21', txt: '腾讯大王卡（新）' },
					// { val: '25', txt: '腾讯大王卡-129版' },
					// { val: '5', txt: '腾讯天王卡' },
					// { val: '2', txt: '阿里宝卡-大宝卡' },
					// { val: '6', txt: '阿里宝卡-轻享版' },
					// { val: '3', txt: '头条懂我卡' },
					// { val: '4', txt: '米粉卡' },
					// { val: '7', txt: '哔哩哔哩卡' },
					// { val: '8', txt: '菜鸟宝卡' },
					// { val: '10', txt: '联通小驿卡' },
					// { val: '11', txt: '天神卡-钻石版' },
					// { val: '9', txt: '移动花卡' },
					// { val: '12', txt: '亲子卡' },
					// { val: '13', txt: '孝心卡' },
					// { val: '14', txt: '畅听王卡' },
					// { val: '15', txt: '电信星卡-29元' },
					// { val: '16', txt: '电信星卡-59元' },
					// { val: '18', txt: '电信畅享卡' },
					// { val: '17', txt: '菜鸟宝卡-MINI' },
					// { val: '19', txt: '联通百合卡' },
					// { val: '20', txt: '联通百合卡（全国）' },
					// { val: '22', txt: '大驿卡' },
					// { val: '23', txt: '大银铃卡' },
					// { val: '24', txt: '小银铃卡' },
					// { val: '26', txt: '大橙卡' },
					// { val: '27', txt: '小菜菜卡' },
					// { val: '28', txt: '大菜菜卡' },
					// { val: '29', txt: '电信和韵卡' },
					// { val: '30', txt: '联通橙卡' },
					// { val: '31', txt: '移动梦起卡' },
					// // { val: '32', txt: '银龄天龙卡' }
					// { val: '33', txt: '电信彗星卡' },
					// { val: '34', txt: '新菜鸟小宝卡' },
					// { val: '35', txt: '新菜鸟大宝卡' },
					// { val: '36', txt: '联通乐享卡' },
					// { val: '37', txt: '联通云燕卡A' },
					// { val: '38', txt: '联通王卡限定版' },
					// { val: '39', txt: '腾讯王卡限定版' },
					// { val: '40', txt: '移动95G' },
					// { val: '41', txt: '冲浪卡' },
					// { val: '42', txt: '联通大乐卡' }
				],
				params: {
					s_id: '',
					s_name: '',
					s_pass_id: '',
					s_status: '',
					ss_name: 'like',
					page: 1,
					pagesize: 10
				},
				dialogVisible: false,
				sub: {
					id: '',
					name: '',
					pass_id: '',
					selectp: '',
					type: '',
					image: '',
					fee: '',
					description: '',
					memo: '',
					jsfs: '',
					jslx: '1',
					bjsfs: '',
					tcgsd: '',
					nlxz: '',
					jfdq: '',
					weigh: '',
					status: '1',
					address_fixed: '',
					kaka: [{
						goodsid: '',
						name: ''
					}],
					page_code: '',
					page_mb: '',
					sc_money: '',
					limit_jh: '',
					limitcontent: '',
					limit_code: '0',
					limit_order_city: [],
					options: [],
					zdjs:'0',
					type_reward: '0',
					default_diff: '',
					zd: '0',
					zdid: '',
					xdnum: 0,
					xd: '',
					xdstart: '',
          small_age: '0',
          big_age: '0',
				},
				rules: {
					name: [{
						required: true,
						message: '商品名称不能为空',
						trigger: 'blur'
					}],
					pass_id: [{
						required: true,
						message: '请选择渠道',
						trigger: 'blur'
					}],
					type: [{
						required: true,
						message: '请选择类型',
						trigger: 'blur'
					}],
					image: [{
						required: true,
						message: '商品主图不能为空',
						trigger: 'blur'
					}],
					fee: [{
						required: true,
						message: '佣金不能为空',
						trigger: 'blur'
					}],
					description: [{
						required: true,
						message: '描述不能为空',
						trigger: 'blur'
					}],
					memo: [{
						required: true,
						message: '推广要求不能为空',
						trigger: 'blur'
					}],
					sc_money: [{
						required: true,
						message: '首充不能为空',
						trigger: 'blur'
					}]
				},
				resetOneShow: false,
				glist: [],
				subset: {
					id: '',
					goods_id: '',
					type: 2
				}

			}
		},
		created() {
			passage_list().then(res => {
				this.passlist = res.data
			})
			goods_list().then(res => {
				this.goodslist = res.data
			})
			muban_list().then(res => {
				this.mblist = res.data
			})
			this.getList()
		},
		methods: {
			rrqx(){
				this.rrshow = false
				this.form.type='1'
				this.form.fee=''
			},
			rrform(){
					if (this.form.fee == null || this.form.fee < 0) {
						this.$message.error('金额不正确')
						return
					}
					goods_reset({
						id: this.rrid,
						fee: this.form.fee,
						type: this.form.type
					}).then(res => {
						this.$message.success(res.msg)
						this.rrshow = false
						this.form.type='1'
						this.form.fee=''
					})
			},
			getList() {
				this.emtypetxt = '加载中...'
				this.loading = true
				goods_index(this.params).then(res => {
					this.list = res.data.list
					this.total = res.data.total
					this.loading = false
					if (this.list.length == 0) {
						this.emtypetxt = '暂无数据'
					}
				})
			},

			handleSearch() {
				this.list = []
				this.params.page = 1
				this.getList()
			},
			// 分页
			handleSizeChange(val) {
				this.params.pagesize = val
				this.getList()
			},
			handleCurrentChange(val) {
				this.params.page = val
				this.getList()
			},
			add() {
				this.sub = {
					id: '',
					name: '',
					pass_id: '',
					type: '1',
					image: '',
					fee: '',
					description: '',
					memo: '',
					jsfs: '',
					jslx: '1',
					bjsfs: '',
					tcgsd: '',
					nlxz: '',
					jfdq: '',
					weigh: '',
					status: '1',
					selectp: '1',
					zd: '0',
					zdid: '',
					xdstart: '',
					xd: '0',
					xdnum: 0,
					kaka: [{
						goodsid: '',
						name: ''
					}],
					page_code: '',
					page_mb: '',
					sc_money: '',
					limit_jh: '',
					limitcontent: '',
					address_fixed: '',
					limit_code: '0',
					limit_order_city: [],
					props: { multiple: true },
					options: [],
					type_reward: '0',
					zdjs: '0',
					default_diff: '',
					small_age: '0',
					big_age: '0',
				}
				goods_city_list({ type: this.sub.type }).then(res => {
					this.sub.options = res.data
					// this.dialogVisible = true
					// console.log(res,"返回的值");
				})
				this.dialogVisible = true
			},
			edit(row) {
				this.sub = {
					id: row.id,
					name: row.name,
					pass_id: row.pass_id,
					type: row.type + '',
					image: row.image,
					selectp: row.selectp + '',
					fee: row.fee,
					description: row.description,
					memo: row.memo,
					bjsfs: row.bjsfs,
					jsfs: row.jsfs,
					jslx: row.jslx+ '',
					tcgsd: row.tcgsd,
					nlxz: row.nlxz,
					jfdq: row.jfdq,
					weigh: row.weigh,
					status: row.status + '',
					kaka: row.kaka,
					page_code: row.page_code,
					page_mb: row.page_mb + '',
					sc_money: row.sc_money,
					limit_jh: row.limit_jh,
					limitcontent: row.limitcontent,
					address_fixed: row.address_fixed,
					limit_code: row.limit_code + '',
					limit_order_city: row.limit_order_city,
					props: { multiple: true },
					options: [],
					type_reward: row.type_reward + '',
					zdjs: row.zdjs + '',
					default_diff: row.default_diff,
					small_age: row.small_age,
					big_age: row.big_age,
					zd: row.zd + '',
					zdid: row.zdid+'',
					xdnum: row.xdnum,
					xd: row.xd+'',
					xdstart: row.xdstart,

					
				}
				// this.dialogVisible = true
				goods_city_list({ type: this.sub.type }).then(res => {
					this.sub.options = res.data
					this.dialogVisible = true
				})
			},
			setCityList() {
				goods_city_list({ type: this.sub.type }).then(res => {
					this.limit_order_city = []
					this.sub.options = res.data
					// console.log(res.data,"城市");
				})
				// console.log(this.sub.limit_order_city,"下单限制城市");
			},
			changeSubType() {
				if (this.sub.type == 3 && this.sub.oldType == 1) {
					this.sub.oldType = this.sub.type
					return
				}
				if (this.sub.type == 1 && this.sub.oldType == 3) {
					this.sub.oldType = this.sub.type
					return
				}
				this.setCityList()
			},
			subForm(formName) {
				this.$refs[formName].validate((valid) => {
					if (valid) {
						if (this.sub.id > 0) {
							goods_edit_post(this.sub).then(res => {
								this.$message.success(res.msg)
								this.dialogVisible = false
								this.getList()
							})
						} else {
							goods_add_post(this.sub).then(res => {
								this.$message.success(res.msg)
								this.dialogVisible = false
								this.getList()
							})
						}
					} else {
						return false
					}
				})
			},
			modalPicTap(tit, num, i) {
				const _this = this
				_this.$modalUpload(function(img) {
					if (tit === '1' && !num) {
						_this.sub.image = img[0]
					}
				}, tit)
			},
			addparams() {
				if (this.sub.kaka.length > 5) {
					return this.$message.error('最多只能添加6个参数')
				}
				this.sub.kaka.push({
					'goodsid': '',
					'name': ''
				})
			},
			removeparams(index) {
				this.sub.kaka.splice(index, 1)
			},
			// 佣金重置
			reset(row) {
				this.rrshow=true
				this.rrid=row.id
				// this.$prompt('差价修改该商品的佣金', '差价重置佣金', {
				// 	confirmButtonText: '确定',
				// 	cancelButtonText: '取消',
				// 	inputPattern: /^[0-9]*$/,
				// 	inputErrorMessage: '金额不正确'
				// }).then(({
				// 	value
				// }) => {
				// 	if (value == null || value < 0) {
				// 		this.$message.error('金额不正确')
				// 		return
				// 	}
				// 	goods_reset({
				// 		id: row.id,
				// 		fee: value,
				// 		type: 1
				// 	}).then(res => {
				// 		this.$message.success(res.msg)
				// 		this.dialogVisible = false
				// 	})
				// })
			},
			// 佣金同步
			resetOne(row) {
				this.subset.id = row.id
				goods_reset_get().then(res => {
					this.glist = res.data.list
					this.resetOneShow = true
				})
			},
			// 佣金同步保存
			subReset() {
				if (!this.subset.id) {
					return this.$message.error('ID不能为空')
				}
				if (!this.subset.goods_id) {
					return this.$message.error('同步商品不能为空')
				}
				if (this.subset.id == this.subset.goods_id) {
					return this.$message.error('同步不能选择自身')
				}

				goods_reset(this.subset).then(res => {
					this.$message.success(res.msg)
					this.resetOneShow = false
				})
			}

		}
	}
</script>

<style lang="scss" scoped>

</style>
